<?php
class Communities extends MY_Controller{

	function __construct()
	{
		parent::__construct();

		if(!$this->admin) redirect('admin990/login');
	}


	function index()
	{
		if($_POST)
		{
			if($_POST['status']=='null'){$status=null;}else{$status=$_POST['status']; }
			$com_status = community::find_by_id($_POST['id']);
			$com_status->status = $status;
			$com_status->delivery = $_POST['shop_id'];
			$com_status->limit_price = $_POST['limit_price'];
			if($com_status->save()){

				redirect('admin990/communities');
			}else{
					
				echo 'not ok';
			}
				
		}else{
			$data['title'] = "Communes";
			$data['admin'] = $this->admin;
			$data['shop'] = shop::find('all');
			$data['coms'] = community::find('all',array('order'=>'code asc'));
			$this->load->view('admin/header',$data);
			$this->load->view('admin/community');
		}
	}


}